package cn.anicert.zk.util;

import org.I0Itec.zkclient.exception.ZkMarshallingError;
import org.I0Itec.zkclient.serialize.ZkSerializer;

/**
 * 字符串序列化/反序列化类.
 * 
 * @author liujd
 * @version Revision 1.0.0
 * *修改时间         | 修改内容
 *
 */
public class StringSerializer implements ZkSerializer {
    
    @Override
    public byte[] serialize(Object data) throws ZkMarshallingError {
        return data == null ? null
            : data.toString().getBytes();
    }
    
    @Override
    public Object deserialize(byte[] bytes) throws ZkMarshallingError {
        return new String(bytes);
    }
}
